<!--
 * @Description: 订单页面
 * @Author: lucl
 * @Date: 2021-06-24 16:50:32
 * @LastEditors: lucl
 * @LastEditTime: 2021-06-27 20:50:59
-->

<template>
  <div>
    <!-- {{ Alldata }} -->
    <el-button type="text" size="big" @click="goback()">返回</el-button>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="订单编号" width="180" />

      <el-table-column prop="productId" label="产品编号" width="180" />
      <el-table-column prop="product.name" label="产品" />
      <el-table-column label="产品图片">
        <template slot-scope="scope">
          <el-popover
            placement="right"
            width="230"
            trigger="hover"
          >
            <el-image
              style="width: 200px; height: 200px"
              :src="scope.row.product.photo"
            />
            <div slot="reference" style="width:50px">
              <el-image
                style="width: 50px; height: 50px"
                :src="scope.row.product.photo"
              />
            </div>
          </el-popover>

        </template>
      </el-table-column>
      <el-table-column prop="product.price" label="单价" />
      <el-table-column prop="number" label="数量" />
    </el-table>
    <!-- {{uid}} -->
    <div style="display: flex;">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>订单基本信息</span>
        </div>
        <div class="text item">
          <div>订单编号：{{ uid }}</div>
          <div>订单金额：<span style="font-size: 18px;">
            ￥<span style="color:red;width:30px;">{{ Alldata.total }}</span>元
          </span>
          </div>
          <div>下单时间：{{ Moment(Alldata.customer.certificationTime).format('YYYY-MM-DD hh:mm:ss') }}</div>
          <div>订单状态：{{ Alldata.status }}</div>
        </div>
      </el-card>

      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <div>接单者信息：</div>
        </div>
        <div class="text item">
          <div>接单者：{{ Alldata.employee.username }}</div>
          <div>接单者手机：{{ Alldata.employee.telephone }}</div>
        </div>
      </el-card>

      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <div>下单者信息：</div>
        </div>
        <div class="text item">
          <div>下单者：{{ Alldata.customer.realname }}</div>
          <div>下单者手机：{{ Alldata.customer.telephone }}</div>
        </div>
      </el-card>

      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <div>雇主信息</div>
        </div>
        <div class="text item">
          <div>雇主：{{ Alldata.address.username }}</div>
          <div>雇主手机号：{{ Alldata.address.telephone }}</div>
          <div>
            服务地址：{{
              Alldata.address.city +
                Alldata.address.area +
                Alldata.address.address
            }}
          </div>
        </div>
      </el-card>
    </div>

  </div>
</template>

<script>
import { findById } from '@/api/order'
import Moment from 'moment'
export default {
  // name:'Order_datails',
  data() {
    return {
      // photoURL:'',
      address: [],
      // 表格数组
      tableData: [],
      // 要查询订单的id
      uid: 1,
      Alldata: { customer: {}, address: {}, employee: {}}
    }
  },
  computed: {},
  created() {
    this.findData()
  },
  mounted() {},
  methods: {
    Moment,
    // 返回菜单页
    goback() {
      this.$router.back()
    },
    async findData() {
      this.uid = this.$route.query.cid
      console.log(this.$route.query)
      const res = await findById({ id: this.uid })
      this.Alldata = res.data
      this.tableData = res.data.orderLines
      this.address = res.data.address
      // this.photoURL=this.tableData
      // console.log(this.photoURL)
    }
  }
}
</script>
<style scoped>
*{
  font-size: 18px;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 250px;
  float: left;
  margin: 10px;

}
</style>
